package com.model.tree;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.control.MyTreeControl;
import com.model.Node;
import com.model.Tree;

public class testTree {

	public static  <T> void main(String[] args) {
		Node<String> root = new Node<String>("磁盘目录",-1,0,0);  
		//root.setStart(0);
        MyTreeControl<String> tree = new MyTreeControl<String>(root);  
        Node<String> b = new Node<String>("系统盘");  
        //b.setStart(0);
        tree.add(b,root,0);  
         
        //System.out.println("\\\\\\\\\\"); 
        //List<Node<String>> list= tree.getAllNodes();
        //for(Node<String> n:list){
        	//System.out.println(n.getData().toString()); 
       // }
        //System.out.println("\\\\\\\\\\"); 
        //System.out.println("删除"+tree.getNode(5).getData().toString());
        //tree.removeNode(5);
       // System.out.println("\\\\\\\\\\"); 
        //List<Node<String>> list1= tree.getAllNodes();
        //for(Node<String> n:list1){
        	//System.out.println(n.getData().toString()); 
        //}
       // System.out.println("\\\\\\\\\\"); 
       // System.out.println(tree.getPath(1));  
       // System.out.println(tree.getRoot().getData());
        Tree trees = tree.getTree();
       // tree.praseJson();
        String aaa = JSON.toJSONString(trees);
        System.out.println(aaa);  
        Tree test = JSONObject.parseObject(aaa,Tree.class);
        List<Node<T>> lists= test.getNodes();
        Object[] object = lists.toArray();
        MyTreeControl<String> myTree = new MyTreeControl<String>(test);
        System.out.println(myTree.getAllNodes().toString());   
        myTree.praseJson();
       // myTree.praseJson();
        //List<Node<String>> list= tree.getAllNodes();
        //for(int i =0;i<list.size();i++)
       // System.out.println(list.get(i).getMyself());
        //for(Node<String> pNode : list){
        	//System.out.print(pNode.getParent());
            //System.out.println(pNode.getData().toString());
            //System.out.println(pNode.getMyself());
            //System.out.println("-------------");
            //if(pNode.getChildNodes().size()>0){
            	//for(Node<String> p : pNode.getChildNodes()){
            		
            		//System.out.println(p.getMyself());
            	//}
            //}
           // System.out.println("-------------");

        //}
        //tree.removeNode(1);
        //List<Node<String>> list1 = tree.getAllNodes();
        //for(Node<String> p:list1){
        //	System.out.println("@@@");
        //	System.out.println(p.getData().toString());
        //}
        //System.out.println(tree.getDepth());  
        //tree.add(new Node<String>("H"),g);  
        //System.out.println(tree.getDepth());  
        //tree.enlarge();  
        //tree.add(b,root); 
        //tree.removeNode(1);
        List<Node<String>> list2 = tree.getAllNodes();
        //for(Node<String> p:list2){
        //	System.out.println("-----");
        //	System.out.println(p.getData().toString());
        //	System.out.println(p.getMyself());
        //}

	}

}
